<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/1/17
 * Time: 13:15
 */
namespace app\mtsuperadmin\controller;

use app\api\model\MtUserInvoice;
use app\util\ReturnCode;

/**
 * 发票管理
 * Class AdminSysInvoic
 * @package app\mtsuperadmin\controller
 */
class AdminSysInvoic extends Base
{
    /**
     * 获取发票列表
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getInvoicList(){
        $term = $this->request->get("term");
        $p = intval($this->request->get("p")) ? intval($this->request->get("p")) : "1";
        $limit = intval($this->request->get("limit")) ? intval($this->request->get("limit")) : config("adminapi.ADMIN_LIST_DEFAULT");
        if($term){
            $where = [$term,"=",$term];
        }else{
            $where = "1=1";
        }
        $sqlRes = (new MtUserInvoice())->where($where)->page($p,$limit)->select();
        if(!$sqlRes){
            return $this->error(ReturnCode::DB_READ_ERROR,"查询失败");
        }
        return $this->success("查询成功",$sqlRes);
    }

}